package com.my.chapter20;

import net.mindView.atunit.TestProperty;
import net.mindview.util.OSExecute;

public class practice10 {
    TrafficLight testObject = new TrafficLight();
    @net.mindView.atunit.Test void initialization() {
        assert testObject.toString().equals(str(Signal.RED));
    }
    @net.mindView.atunit.Test void _change() {
        testObject.change();
        assert testObject.toString().equals(str(Signal.GREEN));
        testObject.change();
        assert testObject.toString().equals(str(Signal.YELLOW));
        testObject.change();
        assert testObject.toString().equals(str(Signal.RED));
    }
    @TestProperty
    private static String str(Signal s) {
        return "The traffic light is " + s;
    }
    public static void main(String[] args) throws Exception {
        OSExecute.command("java " +
                " net.mindView.atunit.AtUnit practice10");
    }
}

enum Signal { GREEN, YELLOW, RED, }

class TrafficLight {
    Signal color = Signal.RED;
    public void change() {
        switch(color) {
            // Note that you don't have to say Signal.RED
            // in the case statement:
            case RED: color = Signal.GREEN;
                break;
            case GREEN: color = Signal.YELLOW;
                break;
            case YELLOW: color = Signal.RED;
                break;
        }
    }
    public String toString() {
        return "The traffic light is " + color;
    }
}

